@layout("/common/default.html",{title:'管理'}){
<fieldset class="table-search-fieldset">
    <legend>搜索信息</legend>
    <div style="margin: 10px 10px 10px 10px">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">

                <div class="layui-inline">
                    <button class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="search">
                        <i class="layui-icon"></i> 搜 索
                    </button>
                @if(shiro.hasPermission('quartzLog:add')){
                    <button type="button" class="layui-btn icon-btn layui-btn-radius" data-type="add">
                        <i class="layui-icon">&#xe654;</i>添加
                    </button>
                    @}
                </div>
            </div>
        </form>
    </div>
</fieldset>

<!--数据表格-->
<table class="layui-table" id="tableId" lay-filter="tableFilter" ></table>


<!-- 操作 -->
<script type="text/html" id="table-toolbar">

    @if(shiro.hasPermission('quartzLog:view')){
        <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-radius" lay-event="view"><i
                    class="layui-icon layui-icon-list"></i>查看</a>
        @}
     @if(shiro.hasPermission('quartzLog:edit')){
        <a class="layui-btn layui-btn-primary layui-btn-xs layui-btn-radius" lay-event="edit"><i
                class="layui-icon layui-icon-edit"></i>编辑</a>
        @}
    @if(shiro.hasPermission('quartzLog:delete')){
        <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-radius" lay-event="del"><i
                class="layui-icon layui-icon-delete"></i>删除</a>
        @}
</script>

<script>

    layui.use(['table','form','utils', 'resAjax', 'openLayer'], function () {

        var table = layui.table,
            form = layui.form,
            laydate = layui.laydate,
            openLayer = layui.openLayer,
            utils = layui.utils;



        var tableData = table.render({
            elem: "#tableId",
            url: "/quartz/quartzLog/dataList",
            page: true,
            limit: 10,
            height: 'full-220',
            cols: [[
               {title: '序号',type: 'numbers', fixed: 'left'},
               {title: '更新时间',field: 'updateDate'},
               {title: '备注信息',field: 'remarks'},
               {title: '操作', align: 'center', width:211, fixed: 'right', toolbar: '#table-toolbar'}
    ]],
        done: function (res, curr, count) {
        }
    });


        //监听搜索
        form.on("submit(search)", function (data) {
            var  field=data.field;
            tableData.reload({
                where: field,
            });
            return false;
        });


        table.on("tool(tableFilter)", function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case "view":
                    view(data.id);
                    break;
                case "edit":
                    edit(data.id);
                    break;
                case "del":
                    del(data.id);
                    break;
            }
        });


        function view(id) {
            openLayer.opneView({
                   url:"/quartz/quartzLog/form",
                   value:id
               })
        }
        function edit(id) {
            openLayer.opneEdit({
                   url:"/quartz/quartzLog/form",
                   value:id
               })
        }

        function del(id) {
            openLayer.confirm("确定要删除吗？", function () {
                utils.ajax("/quartz/quartzLog/delete?id="+ id, "post").done(function (result) {
                    if(result.code=="0"){
                        utils.tableSuccessMsg(result.msg);
                    }else {
                        utils.tableSuccessMsg("删除失败");
                    }
                    tableData.reload();
                }).fail(function (error) {
                });
            })
        }

        //事件
        var active = {
            add: function () {
                openLayer.opneAdd({
                       url:"/quartz/quartzLog/form"
                   })
            },

            reset: function () {
                $('.layui-form input').val('');
                $('.layui-form .layui-inline:last button:first').click();
            }
        };
        $('[data-type]').click(function(){
            var type = $(this).data('type');
            active[type].call(this);
        });

    })

</script>


@}
